home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Tools - Objects / MacApp / MacApp CD Release / MacApp 2.0.1 (Many Libraries) / Tools / MABuildTool.p < prev    next >
Encoding:
Text File  |  1990-10-25  |  51.5 KB  |  2,016 lines  |  [TEXT/MPS ]

  1. {[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]}
  2. {------------------------------------------------------------------------------
  3.  
  4. FILE MABuildTool.p
  5.  Copyright © 1986-1990 Apple Computer, Inc.  All rights reserved.
  6.  
  7. NAME
  8.  MABuild -- process MABuild options
  9.  
  10. SYNOPSIS
  11.  MABuild
  12.  
  13. DESCRIPTION
  14. ------------------------------------------------------------------------------}
  15. PROGRAM MABuild;
  16.  
  17.     USES
  18.         { • MacApp }
  19.         UMacApp, UAssociation,
  20.  
  21.         { • Building Blocks }
  22.         UMPWTool,
  23.  
  24.         { • Required for this unit's interface }
  25.  
  26.         { • Implementation use }
  27.         Memory, CursorCtl, Signal, PasLibIntf, IntEnv, ToolUtils, OSUtils, Packages;
  28.  
  29.     CONST
  30.         { Keyword IDs }
  31.         kwAsm                = 1;
  32.         kwC                 = 2;
  33.         kwCPlus             = 3;
  34.         kwLib                = 4;
  35.         kwLink                = 5;
  36.         kwMake                = 6;
  37.         kwPascal            = 7;
  38.         kwRez                = 8;
  39.         kwPostRez            = 9;
  40.         kwd                 = 10;
  41.         kwRenameFlag        = 11;
  42.         kwPP                = 12;
  43.         kwNoPP                = 13;
  44.         kwTT                = 14;
  45.         kwNoTT                = 15;
  46.         kwAlign             = 16;
  47.         kwNoAlign            = 17;
  48.         kwSeparateObjects    = 18;
  49.         kwNoSeparateObjects = 19;
  50.         kwExecute            = 20;
  51.         kwNoExecute         = 21;
  52.         kwFail                = 22;
  53.         kwNoFail            = 23;
  54.         kwLinkMap            = 24;
  55.         kwNoLinkMap         = 25;
  56.         kwLinkXRef            = 26;
  57.         kwNoLinkXRef        = 27;
  58.         kwAutoBuild         = 28;
  59.         kwNoAutoBuild        = 29;
  60.         kwUserAutoBuild     = 30;
  61.         kwNoUserAutoBuild    = 31;
  62.         kwMacApp            = 32;
  63.         kwNoMacApp            = 33;
  64.         kwDebugTheDebugger    = 34;
  65.         kwNoDebugTheDebugger = 35;
  66.         kwDebug             = 36;
  67.         kwNoDebug            = 37;
  68.         kwBottleNeck        = 38;
  69.         kwNoBottleNeck        = 39;
  70.         kwExpandEnvVars     = 40;
  71.         kwNoExpandEnvVars    = 41;
  72.         kwSave                = 42;
  73.         kwNoSave            = 43;
  74.         kwRun                = 44;
  75.         kwNoRun             = 45;
  76.         kwInspector         = 47;
  77.         kwNoInspector        = 48;
  78.         kwUnInit            = 49;
  79.         kwNoUnInit            = 50;
  80.         kwRangeCheck        = 51;
  81.         kwNoRangeCheck        = 52;
  82.         kwNames             = 53;
  83.         kwNoNames            = 54;
  84.         kwSym                = 55;
  85.         kwNoSym             = 56;
  86.         kwTrace             = 57;
  87.         kwNoTrace            = 58;
  88.         kwNeedsROM128k        = 59;
  89.         kwNoNeedsROM128k    = 60;
  90.         kwNeedsColorQD        = 61;
  91.         kwNoNeedsColorQD    = 62;
  92.         kwPerform            = 63;
  93.         kwNoPerform         = 64;
  94.         kwNeedsSystem6        = 65;
  95.         kwNoNeedsSystem6    = 66;
  96.         kwROM128K            = 67;
  97.         kwNeedsMC68020        = 68;
  98.         kwNoNeedsMC68020    = 69;
  99.         kwNeedsMC68030        = 70;
  100.         kwNoNeedsMC68030    = 71;
  101.         kwNeedsFPU            = 72;
  102.         kwNoNeedsFPU        = 73;
  103.         kwTemplateViews     = 76;
  104.         kwNoTemplateViews    = 77;
  105.         kwStatusOnly        = 80;
  106.         kwNoStatusOnly        = 81;
  107.         kwE                 = 82;
  108.         kwR                 = 83;
  109.         kwS                 = 84;
  110.  
  111.         kwMALibrary         = 85;
  112.         kwNoMALibrary        = 86;
  113.  
  114.         kwCPlusSupport        = 87;
  115.         kwNoCPlusSupport    = 88;
  116.  
  117.         kwExperimentalAndUnsupported = 89;
  118.         kwNoExperimentalAndUnsupported = 90;
  119.  
  120.         kwPasLoad            = 91;
  121.         kwNoPasLoad         = 92;
  122.  
  123.         kwCPlusLoad         = 93;
  124.         kwNoCPlusLoad        = 94;
  125.  
  126.         kHelpStr            = 129;                        { Resource ID of the stringlist printed for
  127.                                                          help }
  128.  
  129.     TYPE
  130.         PText                = ^TEXT;
  131.  
  132.         TStringHandle        = OBJECT (TObject)
  133.             fHandle:            Handle;
  134.             PROCEDURE TStringHandle.WriteToFile(theFile: PText);
  135.             PROCEDURE TStringHandle.Catenate(theString: Str255);
  136.             PROCEDURE TStringHandle.CatenateToFront(theString: Str255);
  137.             PROCEDURE TStringHandle.IStringHandle;
  138.             FUNCTION TStringHandle.AsStr255: Str255;
  139.             PROCEDURE TStringHandle.Free; OVERRIDE;
  140.             END;
  141.  
  142.         TMABuildTool        = OBJECT (TMPWTool)
  143.             fMacApp:            Boolean;
  144.  
  145.             fDebugTheDebugger:    Boolean;
  146.             fDebug:             Boolean;
  147.             fInspector:         Boolean;
  148.             fNames:             Boolean;
  149.             fRangeCheck:        Boolean;
  150.             fPerform:            Boolean;
  151.             fSym:                Boolean;
  152.             fTrace:             Boolean;
  153.             fUnInit:            Boolean;
  154.             fAlign:             Boolean;
  155.             fSeparateObjects:    Boolean;
  156.             fSeparateObjectsFolder: Str255;
  157.             fMALibrary:         Boolean;
  158.             fPasLoad:            Boolean;                { Make Pascal's symbol table dumps external
  159.                                                          files instead of the default of using the
  160.                                                          source file's resource fork }
  161.             fCPlusLoad:         Boolean;                { Create load/dump files for C++ }
  162.  
  163.             fCPlusSupport:        Boolean;
  164.             fExperimentalAndUnsupported: Boolean;        { True if the user want to flirt with
  165.                                                          certain destruction }
  166.  
  167.             fNeedsColorQD:        Boolean;
  168.             fNeedsMC68020:        Boolean;
  169.             fNeedsMC68030:        Boolean;
  170.             fNeedsFPU:            Boolean;
  171.             fNeedsSystem6:        Boolean;
  172.             fNeedsROM128K:        Boolean;
  173.             fTemplateViews:     Boolean;
  174.  
  175.             fAllProgress:        Boolean;
  176.             fExecute:            Boolean;
  177.             fAutoBuild:         Boolean;
  178.             fUserAutoBuild:     Boolean;
  179.             fNoFail:            Boolean;
  180.             fLinkMap:            Boolean;
  181.             fLinkXRef:            Boolean;
  182.             fStatusOnly:        Boolean;
  183.             fTimes:             Boolean;
  184.             fRunAfterBuild:     Boolean;
  185.             fSaveBeforeBuild:    Boolean;
  186.             fBottleNeckedDispatching: Boolean;
  187.             fExpandEnvironmentVars: Boolean;
  188.  
  189.             fEverExported:        Boolean;                { only need to export once }
  190.  
  191.             fAsmOptions:        TStringHandle;
  192.             fCOptions:            TStringHandle;
  193.             fCPlusOptions:        TStringHandle;
  194.             fEchoOptions:        TStringHandle;
  195.             fLibOptions:        TStringHandle;
  196.             fLinkOptions:        TStringHandle;
  197.             fMakeOptions:        TStringHandle;
  198.             fPascalOptions:     TStringHandle;
  199.             fRezOptions:        TStringHandle;
  200.             fPostRezOptions:    TStringHandle;
  201.  
  202.             fTargStringList:    TList;
  203.             fOptionFlags:        TStringHandle;
  204.  
  205.             fOutputFile:        PText;
  206.  
  207.             fRenameFlagsPairs:    TAssociation;
  208.  
  209.             PROCEDURE TMABuildTool.IMABuildTool;
  210.  
  211.             PROCEDURE TMABuildTool.DoProcessFileArg(arg: Str255); OVERRIDE;
  212.             PROCEDURE TMABuildTool.DoProcessOptionArg(kw: integer); OVERRIDE;
  213.             PROCEDURE TMABuildTool.DoShowUsage; OVERRIDE;
  214.             PROCEDURE TMABuildTool.DoStartProgress; OVERRIDE;
  215.             PROCEDURE TMABuildTool.DoToolAction; OVERRIDE;
  216.             PROCEDURE TMABuildTool.DoAllTargets;
  217.             PROCEDURE TMABuildTool.InstallKeyWords; OVERRIDE;
  218.             PROCEDURE TMABuildTool.EachSourceToolOptionStringDo(PROCEDURE
  219.                                                                 DoToOptionString(itsStringHandle:
  220.                                                                                  TStringHandle));
  221.             PROCEDURE TMABuildTool.CatenateToSourceOptionStrings(newText: Str255);
  222.             PROCEDURE TMABuildTool.Echo(aStr: Str255);
  223.             PROCEDURE TMABuildTool.Execute(aStr: Str255);
  224.             PROCEDURE TMABuildTool.SetIE(theVariable: Str255;
  225.                                          theValue: Str255); { output a set instruction }
  226.             FUNCTION TMABuildTool.Exists(theFile: Str255): Boolean;
  227.             END;
  228.  
  229.     VAR
  230.         gMABuildTool:        TMABuildTool;                { The tool }
  231.         aFile:                TEXT;                        { output file if specified with -o }
  232.         gDirectorySeparator: Str255;                    { : or / as required by host filesystem }
  233.         StartPath:            Str255;
  234.  
  235. {--------------------------------------------------------------------------------------------------}
  236.         {$S TRes}
  237.  
  238.     FUNCTION NewTStringHandle: TStringHandle;
  239.  
  240.         VAR
  241.             aTStringHandle:     TStringHandle;
  242.  
  243.         BEGIN
  244.         New(aTStringHandle);
  245.         aTStringHandle.IStringHandle;
  246.         NewTStringHandle := aTStringHandle;
  247.         END;
  248.  
  249. {--------------------------------------------------------------------------------------------------}
  250.     {$S TRes}
  251.  
  252.     PROCEDURE TStringHandle.WriteToFile(theFile: PText);
  253.  
  254.         VAR
  255.             remaining:            integer;
  256.             aString:            Str255;
  257.             thisTime, offset:    integer;
  258.  
  259.         BEGIN
  260.         remaining := GetHandleSize(fHandle);
  261.         offset := 0;
  262.         WHILE remaining > 0 DO
  263.             BEGIN
  264.             IF remaining > 255 THEN
  265.                 thisTime := 255
  266.             ELSE
  267.                 thisTime := remaining;
  268.             remaining := remaining - thisTime;
  269.             BlockMove(Ptr(ord(fHandle^) + offset), Ptr(@aString[1]), thisTime);
  270.             offset := offset + thisTime;
  271.             aString[0] := chr(thisTime);
  272.             Write(theFile^, aString);
  273.             END;
  274.         END;
  275.  
  276. {--------------------------------------------------------------------------------------------------}
  277.     {$S TRes}
  278.  
  279.     FUNCTION TStringHandle.AsStr255: Str255;
  280.  
  281.         VAR
  282.             aString:            Str255;
  283.  
  284.         BEGIN
  285.         aString[0] := chr(min(GetHandleSize(fHandle), 255));
  286.         BlockMove(fHandle^, Ptr(@aString[1]), length(aString));
  287.         AsStr255 := aString;
  288.         END;
  289.  
  290. {--------------------------------------------------------------------------------------------------}
  291.     {$S TRes}
  292.  
  293.     PROCEDURE TStringHandle.IStringHandle;
  294.  
  295.         VAR
  296.             aHandle:            Handle;
  297.  
  298.         BEGIN
  299.         fHandle := NIL;
  300.         aHandle := NewHandle(0);
  301.         FailNil(aHandle);
  302.         fHandle := aHandle;
  303.         END;
  304.  
  305. {--------------------------------------------------------------------------------------------------}
  306.     {$S TRes}
  307.  
  308.     PROCEDURE TStringHandle.Free;
  309.  
  310.         BEGIN
  311.         DisposIfHandle(fHandle);
  312.         inherited Free;
  313.         END;
  314.  
  315. {--------------------------------------------------------------------------------------------------}
  316.     {$S TRes}
  317.  
  318.     PROCEDURE TStringHandle.Catenate(theString: Str255);
  319.  
  320.         VAR
  321.             aLong:                Longint;
  322.  
  323.         BEGIN
  324.         aLong := Munger(fHandle, GetHandleSize(fHandle), NIL, 0, { force insertion }
  325.                         Ptr(@theString[1]), length(theString));
  326.         FailMemError;
  327.         END;
  328.  
  329. {--------------------------------------------------------------------------------------------------}
  330.     {$S TRes}
  331.  
  332.     PROCEDURE TStringHandle.CatenateToFront(theString: Str255);
  333.  
  334.         VAR
  335.             aLong:                Longint;
  336.  
  337.         BEGIN
  338.         aLong := Munger(fHandle, 0, NIL, 0,             { force insertion }
  339.                         Ptr(@theString[1]), length(theString));
  340.         FailMemError;
  341.         END;
  342.  
  343. {--------------------------------------------------------------------------------------------------}
  344.     {$S TRes}
  345.  
  346.     PROCEDURE TMABuildTool.DoShowUsage;
  347.  
  348.         VAR
  349.             theHelpString:        Str255;
  350.             i:                    integer;
  351.  
  352.         BEGIN
  353.         PLFlush(diagnostic);
  354.         PLSetVBuf(diagnostic, NIL, _IOFBF, 4096);
  355.  
  356.         { output each string in the stringlist }
  357.         i := 1;
  358.         GetIndString(theHelpString, kHelpStr, i);
  359.         WHILE (theHelpString <> '') DO
  360.             BEGIN
  361.             WriteLn(diagnostic, theHelpString);
  362.             i := succ(i);
  363.             GetIndString(theHelpString, kHelpStr, i);
  364.             END;
  365.         END;
  366.  
  367. {--------------------------------------------------------------------------------------------------}
  368.     {$S TInit}
  369.  
  370.     PROCEDURE TMABuildTool.DoProcessFileArg(arg: Str255);
  371.  
  372.         VAR
  373.             aStringHandle:        TStringHandle;
  374.  
  375.         BEGIN
  376.         { Special case for MacApp as target for backward compatibility (until post 2.0)}
  377.         IF EqualString(arg, 'MacApp', FALSE, TRUE) THEN
  378.             fAutoBuild := TRUE
  379.         ELSE
  380.             BEGIN
  381.             aStringHandle := NewTStringHandle;
  382.             aStringHandle.Catenate(arg);
  383.             fTargStringList.InsertLast(aStringHandle);
  384.             END;
  385.         END;
  386.  
  387. {--------------------------------------------------------------------------------------------------}
  388.     {$S TInit}
  389.  
  390.     PROCEDURE TMABuildTool.DoStartProgress;
  391.  
  392.         VAR
  393.             theDateTimeString:    Str255;
  394.  
  395.         BEGIN
  396.         IUTimeString(fStartDateTime, TRUE, theDateTimeString);
  397.         Write(diagnostic, gProgName, ' - v. 2.0.1 Release ', compdate, '          Start: ',
  398.               theDateTimeString);
  399.  
  400.         IUDateString(fStartDateTime, shortDate, theDateTimeString);
  401.         WriteLn(diagnostic, ' ', theDateTimeString);
  402.  
  403.         WriteLn(diagnostic);
  404.         WriteLn(diagnostic, 'Copyright Apple Computer, Inc. 1986-1990');
  405.         WriteLn(diagnostic, 'All Rights Reserved.');
  406.         WriteLn(diagnostic);
  407.         PLFlush(diagnostic);
  408.         END;
  409.  
  410. {--------------------------------------------------------------------------------------------------}
  411.     {$S TRes}
  412.  
  413.     PROCEDURE TMABuildTool.EachSourceToolOptionStringDo(PROCEDURE
  414.                                                         DoToOptionString(itsStringHandle:
  415.                                                                          TStringHandle));
  416.  
  417.         BEGIN
  418.         DoToOptionString(fAsmOptions);
  419.         DoToOptionString(fCOptions);
  420.         DoToOptionString(fCPlusOptions);
  421.         DoToOptionString(fMakeOptions);
  422.         DoToOptionString(fPascalOptions);
  423.         DoToOptionString(fRezOptions);
  424.         END;
  425.  
  426. {--------------------------------------------------------------------------------------------------}
  427.     {$S TRes}
  428.  
  429.     PROCEDURE TMABuildTool.CatenateToSourceOptionStrings(newText: Str255);
  430.  
  431.         PROCEDURE DoToOptionString(itsStringHandle: TStringHandle);
  432.  
  433.             BEGIN
  434.             itsStringHandle.Catenate(newText);
  435.             END;
  436.  
  437.         BEGIN
  438.         EachSourceToolOptionStringDo(DoToOptionString);
  439.         END;
  440.  
  441. {--------------------------------------------------------------------------------------------------}
  442.     {$S TInit}
  443.  
  444.     PROCEDURE TMABuildTool.DoProcessOptionArg(kw: integer);
  445.  
  446.         VAR
  447.             theNextArg:         Str255;
  448.  
  449.         BEGIN
  450.         CASE kw OF
  451.             kwAsm:
  452.                 BEGIN
  453.                 fAsmOptions.Catenate(' ');
  454.                 fAsmOptions.Catenate(GetNextArg);
  455.                 END;
  456.  
  457.             kwC:
  458.                 BEGIN
  459.                 fCOptions.Catenate(' ');
  460.                 fCOptions.Catenate(GetNextArg);
  461.                 END;
  462.  
  463.             kwCPlus:
  464.                 BEGIN
  465.                 fCPlusOptions.Catenate(' ');
  466.                 fCPlusOptions.Catenate(GetNextArg);
  467.                 END;
  468.  
  469.             kwLib:
  470.                 BEGIN
  471.                 fLibOptions.Catenate(' ');
  472.                 fLibOptions.Catenate(GetNextArg);
  473.                 END;
  474.  
  475.             kwLink:
  476.                 BEGIN
  477.                 fLinkOptions.Catenate(' ');
  478.                 fLinkOptions.Catenate(GetNextArg);
  479.                 END;
  480.  
  481.             kwMake:
  482.                 BEGIN
  483.                 fMakeOptions.Catenate(' ');
  484.                 fMakeOptions.Catenate(GetNextArg);
  485.                 END;
  486.  
  487.             kwPascal:
  488.                 BEGIN
  489.                 fPascalOptions.Catenate(' ');
  490.                 fPascalOptions.Catenate(GetNextArg);
  491.                 END;
  492.  
  493.             kwRez:
  494.                 BEGIN
  495.                 fRezOptions.Catenate(' ');
  496.                 fRezOptions.Catenate(GetNextArg);
  497.                 END;
  498.  
  499.             kwPostRez:
  500.                 BEGIN
  501.                 fPostRezOptions.Catenate(' ');
  502.                 fPostRezOptions.Catenate(GetNextArg);
  503.                 END;
  504.  
  505.             kwd:
  506.                 BEGIN
  507.                 theNextArg := GetNextArg;
  508.  
  509.                 fAsmOptions.Catenate(' -d ');
  510.                 fAsmOptions.Catenate(theNextArg);
  511.  
  512.                 fCOptions.Catenate(' -d ');
  513.                 fCOptions.Catenate(theNextArg);
  514.  
  515.                 fCPlusOptions.Catenate(' -d ');
  516.                 fCPlusOptions.Catenate(theNextArg);
  517.  
  518.                 fMakeOptions.Catenate(' -d ');
  519.                 fMakeOptions.Catenate(theNextArg);
  520.  
  521.                 fPascalOptions.Catenate(' -d ');
  522.                 fPascalOptions.Catenate(theNextArg);
  523.  
  524.                 fRezOptions.Catenate(' -d ');
  525.                 fRezOptions.Catenate(theNextArg);
  526.  
  527.                 END;
  528.  
  529.             kwRenameFlag:
  530.                 BEGIN
  531.                 fRenameFlagsPairs.InsertEntry(GetNextArg, GetNextArg);
  532.                 END;
  533.  
  534.             kwPP:
  535.                 BEGIN
  536.                 fAllProgress := TRUE;
  537.                 fProgress := TRUE;
  538.                 END;
  539.             kwNoPP:
  540.                 BEGIN
  541.                 fAllProgress := FALSE;
  542.                 fProgress := FALSE;
  543.                 END;
  544.  
  545.             kwTT:
  546.                 BEGIN
  547.                 fTimes := TRUE;
  548.                 fTime := TRUE;
  549.                 END;
  550.             kwNoTT:
  551.                 BEGIN
  552.                 fTimes := FALSE;
  553.                 fTime := FALSE;
  554.                 END;
  555.  
  556.             kwAlign:
  557.                 fAlign := TRUE;
  558.             kwNoAlign:
  559.                 fAlign := FALSE;
  560.  
  561.             kwSeparateObjects:
  562.                 fSeparateObjects := TRUE;
  563.             kwNoSeparateObjects:
  564.                 fSeparateObjects := FALSE;
  565.  
  566.             kwExecute:
  567.                 fExecute := TRUE;
  568.             kwNoExecute:
  569.                 fExecute := FALSE;
  570.  
  571.             kwFail:
  572.                 fNoFail := FALSE;
  573.             kwNoFail:
  574.                 fNoFail := TRUE;
  575.  
  576.             kwLinkMap:
  577.                 fLinkMap := TRUE;
  578.             kwNoLinkMap:
  579.                 fLinkMap := FALSE;
  580.  
  581.             kwLinkXRef:
  582.                 fLinkXRef := TRUE;
  583.             kwNoLinkXRef:
  584.                 fLinkXRef := FALSE;
  585.  
  586.             kwAutoBuild:
  587.                 fAutoBuild := TRUE;
  588.             kwNoAutoBuild:
  589.                 fAutoBuild := FALSE;
  590.  
  591.             kwUserAutoBuild:
  592.                 fUserAutoBuild := TRUE;
  593.             kwNoUserAutoBuild:
  594.                 fUserAutoBuild := FALSE;
  595.  
  596.             kwMacApp:
  597.                 fMacApp := TRUE;
  598.             kwNoMacApp:
  599.                 fMacApp := FALSE;
  600.  
  601.             kwDebugTheDebugger:
  602.                 fDebugTheDebugger := TRUE;
  603.             kwNoDebugTheDebugger:
  604.                 fDebugTheDebugger := FALSE;
  605.  
  606.             kwDebug:
  607.                 BEGIN
  608.                 fDebug := TRUE;
  609.                 fInspector := TRUE;
  610.                 fUnInit := TRUE;
  611.                 fPerform := TRUE;
  612.                 fRangeCheck := TRUE;
  613.                 fTrace := TRUE;
  614.                 fNames := TRUE;
  615.                 fBottleNeckedDispatching := TRUE;
  616.                 END;
  617.             kwNoDebug:
  618.                 BEGIN
  619.                 fDebug := FALSE;
  620.                 fInspector := FALSE;
  621.                 fUnInit := FALSE;
  622.                 fPerform := FALSE;
  623.                 fRangeCheck := FALSE;
  624.                 fTrace := FALSE;
  625.                 fNames := FALSE;
  626.                 fBottleNeckedDispatching := FALSE;
  627.                 END;
  628.  
  629.             kwBottleNeck:
  630.                 fBottleNeckedDispatching := TRUE;
  631.             kwNoBottleNeck:
  632.                 fBottleNeckedDispatching := FALSE;
  633.  
  634.             kwExpandEnvVars:
  635.                 fExpandEnvironmentVars := TRUE;
  636.             kwNoExpandEnvVars:
  637.                 fExpandEnvironmentVars := FALSE;
  638.  
  639.             kwSave:
  640.                 fSaveBeforeBuild := TRUE;
  641.             kwNoSave:
  642.                 fSaveBeforeBuild := FALSE;
  643.  
  644.             kwRun:
  645.                 fRunAfterBuild := TRUE;
  646.             kwNoRun:
  647.                 fRunAfterBuild := FALSE;
  648.  
  649.             kwInspector:
  650.                 fInspector := TRUE;
  651.             kwNoInspector:
  652.                 fInspector := FALSE;
  653.  
  654.             kwUnInit:
  655.                 fUnInit := TRUE;
  656.             kwNoUnInit:
  657.                 fUnInit := FALSE;
  658.  
  659.             kwRangeCheck:
  660.                 fRangeCheck := TRUE;
  661.             kwNoRangeCheck:
  662.                 fRangeCheck := FALSE;
  663.  
  664.             kwNames:
  665.                 fNames := TRUE;
  666.             kwNoNames:
  667.                 fNames := FALSE;
  668.  
  669.             kwSym:
  670.                 fSym := TRUE;
  671.             kwNoSym:
  672.                 fSym := FALSE;
  673.  
  674.             kwTrace:
  675.                 fTrace := TRUE;
  676.             kwNoTrace:
  677.                 fTrace := FALSE;
  678.  
  679.             kwNeedsROM128k:
  680.                 fNeedsROM128K := TRUE;
  681.             kwNoNeedsROM128k:
  682.                 fNeedsROM128K := FALSE;
  683.  
  684.             kwNeedsColorQD:
  685.                 fNeedsColorQD := TRUE;
  686.             kwNoNeedsColorQD:
  687.                 fNeedsColorQD := FALSE;
  688.  
  689.             kwPerform:
  690.                 fPerform := TRUE;
  691.             kwNoPerform:
  692.                 fPerform := FALSE;
  693.  
  694.             kwNeedsSystem6:
  695.                 fNeedsSystem6 := TRUE;
  696.             kwNoNeedsSystem6:
  697.                 fNeedsSystem6 := FALSE;
  698.  
  699.             kwROM128K:
  700.                 fNeedsROM128K := TRUE;
  701.  
  702.             kwNeedsMC68020:
  703.                 fNeedsMC68020 := TRUE;
  704.             kwNoNeedsMC68020:
  705.                 fNeedsMC68020 := FALSE;
  706.  
  707.             kwNeedsMC68030:
  708.                 fNeedsMC68030 := TRUE;
  709.             kwNoNeedsMC68030:
  710.                 fNeedsMC68030 := FALSE;
  711.  
  712.             kwNeedsFPU:
  713.                 fNeedsFPU := TRUE;
  714.             kwNoNeedsFPU:
  715.                 fNeedsFPU := FALSE;
  716.  
  717.             kwTemplateViews:
  718.                 fTemplateViews := TRUE;
  719.             kwNoTemplateViews:
  720.                 fTemplateViews := FALSE;
  721.  
  722.             kwStatusOnly:
  723.                 BEGIN
  724.                 fExecute := FALSE;
  725.                 fStatusOnly := TRUE;
  726.                 END;
  727.             kwNoStatusOnly:
  728.                 BEGIN
  729.                 fExecute := TRUE;
  730.                 fStatusOnly := FALSE;
  731.                 END;
  732.  
  733.             kwE:
  734.                 fMakeOptions.Catenate(' -e');
  735.  
  736.             kwR:
  737.                 BEGIN
  738.                 fExecute := FALSE;
  739.                 fStatusOnly := TRUE;
  740.                 fMakeOptions.Catenate(' -r');
  741.                 END;
  742.  
  743.             kwS:
  744.                 BEGIN
  745.                 fExecute := FALSE;
  746.                 fStatusOnly := TRUE;
  747.                 fMakeOptions.Catenate(' -s');
  748.                 END;
  749.  
  750.             kwMALibrary:
  751.                 BEGIN
  752.                 fMALibrary := TRUE;
  753.                 END;
  754.  
  755.             kwNoMALibrary:
  756.                 BEGIN
  757.                 fMALibrary := FALSE;
  758.                 END;
  759.  
  760.             kwPasLoad:
  761.                 BEGIN
  762.                 fPasLoad := TRUE;
  763.                 END;
  764.  
  765.             kwNoPasLoad:
  766.                 BEGIN
  767.                 fPasLoad := FALSE;
  768.                 END;
  769.  
  770.             kwCPlusLoad:
  771.                 BEGIN
  772.                 fCPlusLoad := TRUE;
  773.                 END;
  774.  
  775.             kwNoCPlusLoad:
  776.                 BEGIN
  777.                 fCPlusLoad := FALSE;
  778.                 END;
  779.  
  780.             kwCPlusSupport:
  781.                 BEGIN
  782.                 fCPlusSupport := TRUE;
  783.                 END;
  784.  
  785.             kwNoCPlusSupport:
  786.                 BEGIN
  787.                 fCPlusSupport := FALSE;
  788.                 END;
  789.  
  790.             kwExperimentalAndUnsupported:
  791.                 BEGIN
  792.                 fExperimentalAndUnsupported := TRUE;
  793.                 END;
  794.  
  795.             kwNoExperimentalAndUnsupported:
  796.                 BEGIN
  797.                 fExperimentalAndUnsupported := FALSE;
  798.                 END;
  799.  
  800.             OTHERWISE
  801.                 inherited DoProcessOptionArg(kw);
  802.         END;
  803.  
  804.         END;
  805.  
  806. {--------------------------------------------------------------------------------------------------}
  807.     {$S TInit}
  808.  
  809.     PROCEDURE TMABuildTool.IMABuildTool;
  810.  
  811.         VAR
  812.             anAssociation:        TAssociation;
  813.             aString:            Str255;
  814.  
  815.         BEGIN
  816.         ITool;
  817.  
  818.         { Try to get the appropriate separator character for directories }
  819.         IF IEGetEnv('MADirectorySeparator', aString) THEN
  820.             gDirectorySeparator := aString
  821.         ELSE
  822.             gDirectorySeparator := ':';
  823.  
  824.         fOutputFile := @Output;
  825.         PLFlush(fOutputFile^);
  826.         PLSetVBuf(fOutputFile^, NIL, _IOFBF, 8192);
  827.  
  828.         fRenameFlagsPairs := NIL;
  829.         New(anAssociation);
  830.         anAssociation.IAssociation;
  831.         fRenameFlagsPairs := anAssociation;
  832.  
  833.         { setup the default options }
  834.         fMacApp := TRUE;
  835.  
  836.         fDebugTheDebugger := FALSE;
  837.  
  838.         fDebug := FALSE;
  839.         fInspector := FALSE;
  840.         fNames := FALSE;
  841.         fPerform := FALSE;
  842.         fRangeCheck := FALSE;
  843.         fSym := FALSE;
  844.         fTrace := FALSE;
  845.         fUnInit := FALSE;
  846.         fAlign := TRUE;
  847.         fSeparateObjects := TRUE;
  848.         fSeparateObjectsFolder := '';
  849.         fMALibrary := TRUE;
  850.  
  851.         fPasLoad := FALSE;
  852.         fCPlusLoad := FALSE;
  853.  
  854.         fCPlusSupport := FALSE;
  855.         fExperimentalAndUnsupported := FALSE;
  856.  
  857.         fNeedsColorQD := FALSE;
  858.         fNeedsMC68020 := FALSE;
  859.         fNeedsMC68030 := FALSE;
  860.         fNeedsFPU := FALSE;
  861.         fNeedsSystem6 := FALSE;
  862.         fNeedsROM128K := TRUE;
  863.         fTemplateViews := TRUE;
  864.  
  865.         fAllProgress := FALSE;
  866.         fExecute := TRUE;
  867.         fAutoBuild := FALSE;
  868.         fUserAutoBuild := TRUE;
  869.         fNoFail := FALSE;
  870.         fProgress := FALSE;
  871.         fStatusOnly := FALSE;
  872.         fTimes := FALSE;
  873.         fLinkMap := FALSE;
  874.         fLinkXRef := FALSE;
  875.         fBottleNeckedDispatching := FALSE;
  876.         fRunAfterBuild := FALSE;
  877.         fSaveBeforeBuild := FALSE;
  878.         fExpandEnvironmentVars := FALSE;
  879.  
  880.         fEverExported := FALSE;
  881.  
  882.         fAsmOptions := NIL;
  883.         fCOptions := NIL;
  884.         fCPlusOptions := NIL;
  885.         fEchoOptions := NIL;
  886.         fLibOptions := NIL;
  887.         fLinkOptions := NIL;
  888.         fMakeOptions := NIL;
  889.         fPascalOptions := NIL;
  890.         fRezOptions := NIL;
  891.         fPostRezOptions := NIL;
  892.  
  893.         fAsmOptions := NewTStringHandle;
  894.         fCOptions := NewTStringHandle;
  895.         fCPlusOptions := NewTStringHandle;
  896.         fEchoOptions := NewTStringHandle;
  897.         fLibOptions := NewTStringHandle;
  898.         fLinkOptions := NewTStringHandle;
  899.         fMakeOptions := NewTStringHandle;
  900.         fPascalOptions := NewTStringHandle;
  901.         fRezOptions := NewTStringHandle;
  902.         fPostRezOptions := NewTStringHandle;
  903.  
  904.         fEchoOptions := NIL;
  905.         fTargStringList := NIL;
  906.         fOptionFlags := NIL;
  907.  
  908.         fEchoOptions := NewTStringHandle;
  909.  
  910.         fTargStringList := NewList;
  911.  
  912.         fOptionFlags := NewTStringHandle;
  913.  
  914.         END;
  915.  
  916. {--------------------------------------------------------------------------------------------------}
  917.     {$S TInit}
  918.  
  919.     PROCEDURE TMABuildTool.InstallKeyWords;
  920.  
  921.         BEGIN
  922.         inherited InstallKeyWords;
  923.  
  924.         InstallKeyWord('Asm', kwAsm);
  925.         InstallKeyWord('C', kwC);
  926.         InstallKeyWord('CPlus', kwCPlus);
  927.         InstallKeyWord('Lib', kwLib);
  928.         InstallKeyWord('Link', kwLink);
  929.         InstallKeyWord('Make', kwMake);
  930.         InstallKeyWord('Pascal', kwPascal);
  931.         InstallKeyWord('Rez', kwRez);
  932.         InstallKeyWord('PostRez', kwPostRez);
  933.         InstallKeyWord('d', kwd);
  934.         InstallKeyWord('RenameFlag', kwRenameFlag);
  935.         InstallKeyWord('PP', kwPP);
  936.         InstallKeyWord('NoPP', kwNoPP);
  937.         InstallKeyWord('TT', kwTT);
  938.         InstallKeyWord('NoTT', kwNoTT);
  939.         InstallKeyWord('Align', kwAlign);
  940.         InstallKeyWord('NoAlign', kwNoAlign);
  941.         InstallKeyWord('SeparateObjects', kwSeparateObjects);
  942.         InstallKeyWord('NoSeparateObjects', kwNoSeparateObjects);
  943.         InstallKeyWord('Execute', kwExecute);
  944.         InstallKeyWord('NoExecute', kwNoExecute);
  945.         InstallKeyWord('Fail', kwFail);
  946.         InstallKeyWord('NoFail', kwNoFail);
  947.         InstallKeyWord('LinkMap', kwLinkMap);
  948.         InstallKeyWord('NoLinkMap', kwNoLinkMap);
  949.         InstallKeyWord('LinkXRef', kwLinkXRef);
  950.         InstallKeyWord('NoLinkXRef', kwNoLinkXRef);
  951.         InstallKeyWord('AutoBuild', kwAutoBuild);
  952.         InstallKeyWord('NoAutoBuild', kwNoAutoBuild);
  953.         InstallKeyWord('UserAutoBuild', kwUserAutoBuild);
  954.         InstallKeyWord('NoUserAutoBuild', kwNoUserAutoBuild);
  955.         InstallKeyWord('MacApp', kwMacApp);
  956.         InstallKeyWord('NoMacApp', kwNoMacApp);
  957.         InstallKeyWord('DebugTheDebugger', kwDebugTheDebugger);
  958.         InstallKeyWord('NoDebugTheDebugger', kwNoDebugTheDebugger);
  959.         InstallKeyWord('Debug', kwDebug);
  960.         InstallKeyWord('NoDebug', kwNoDebug);
  961.         InstallKeyWord('BottleNeck', kwBottleNeck);
  962.         InstallKeyWord('NoBottleNeck', kwNoBottleNeck);
  963.         InstallKeyWord('ExpandEnvVars', kwExpandEnvVars);
  964.         InstallKeyWord('NoExpandEnvVars', kwNoExpandEnvVars);
  965.         InstallKeyWord('Save', kwSave);
  966.         InstallKeyWord('NoSave', kwNoSave);
  967.         InstallKeyWord('Run', kwRun);
  968.         InstallKeyWord('NoRun', kwNoRun);
  969.         InstallKeyWord('Inspector', kwInspector);
  970.         InstallKeyWord('NoInspector', kwNoInspector);
  971.         InstallKeyWord('UnInit', kwUnInit);
  972.         InstallKeyWord('NoUnInit', kwNoUnInit);
  973.         InstallKeyWord('RangeCheck', kwRangeCheck);
  974.         InstallKeyWord('NoRangeCheck', kwNoRangeCheck);
  975.         InstallKeyWord('Names', kwNames);
  976.         InstallKeyWord('NoNames', kwNoNames);
  977.         InstallKeyWord('Sym', kwSym);
  978.         InstallKeyWord('NoSym', kwNoSym);
  979.         InstallKeyWord('Trace', kwTrace);
  980.         InstallKeyWord('NoTrace', kwNoTrace);
  981.         InstallKeyWord('NeedsROM128k', kwNeedsROM128k);
  982.         InstallKeyWord('NoNeedsROM128k', kwNoNeedsROM128k);
  983.         InstallKeyWord('NeedsColorQD', kwNeedsColorQD);
  984.         InstallKeyWord('NoNeedsColorQD', kwNoNeedsColorQD);
  985.         InstallKeyWord('Perform', kwPerform);
  986.         InstallKeyWord('NoPerform', kwNoPerform);
  987.         InstallKeyWord('NeedsSystem6', kwNeedsSystem6);
  988.         InstallKeyWord('NoNeedsSystem6', kwNoNeedsSystem6);
  989.         InstallKeyWord('ROM128K', kwROM128K);
  990.         InstallKeyWord('NeedsMC68020', kwNeedsMC68020);
  991.         InstallKeyWord('NoNeedsMC68020', kwNoNeedsMC68020);
  992.         InstallKeyWord('NeedsMC68030', kwNeedsMC68030);
  993.         InstallKeyWord('NoNeedsMC68030', kwNoNeedsMC68030);
  994.         InstallKeyWord('NeedsFPU', kwNeedsFPU);
  995.         InstallKeyWord('NoNeedsFPU', kwNoNeedsFPU);
  996.         InstallKeyWord('TemplateViews', kwTemplateViews);
  997.         InstallKeyWord('NoTemplateViews', kwNoTemplateViews);
  998.         InstallKeyWord('StatusOnly', kwStatusOnly);
  999.         InstallKeyWord('NoStatusOnly', kwNoStatusOnly);
  1000.         InstallKeyWord('E', kwE);
  1001.         InstallKeyWord('R', kwR);
  1002.         InstallKeyWord('S', kwS);
  1003.         InstallKeyWord('PasLoad', kwPasLoad);
  1004.         InstallKeyWord('NoPasLoad', kwNoPasLoad);
  1005.  
  1006.         InstallKeyWord('CPlusLoad', kwCPlusLoad);
  1007.         InstallKeyWord('NoCPlusLoad', kwNoCPlusLoad);
  1008.  
  1009.         InstallKeyWord('MALibrary', kwMALibrary);
  1010.         InstallKeyWord('NoMALibrary', kwNoMALibrary);
  1011.  
  1012.         InstallKeyWord('CPlusSupport', kwCPlusSupport);
  1013.         InstallKeyWord('NoCPlusSupport', kwNoCPlusSupport);
  1014.  
  1015.         InstallKeyWord('ExperimentalAndUnsupported', kwExperimentalAndUnsupported);
  1016.         InstallKeyWord('NoExperimentalAndUnsupported', kwNoExperimentalAndUnsupported);
  1017.  
  1018.         END;
  1019.  
  1020. {--------------------------------------------------------------------------------------------------}
  1021.     {$S TRes}
  1022.  
  1023.     PROCEDURE TMABuildTool.Execute(aStr: Str255);
  1024.  
  1025.         BEGIN
  1026.         WriteLn(fOutputFile^, aStr);
  1027.         END;
  1028.  
  1029. {--------------------------------------------------------------------------------------------------}
  1030.     {$S TRes}
  1031.  
  1032.     PROCEDURE TMABuildTool.SetIE(theVariable: Str255;
  1033.                                  theValue: Str255);
  1034.  
  1035.         BEGIN
  1036.         WriteLn(fOutputFile^, 'SET ', theVariable, ' "', theValue, '"');
  1037.         END;
  1038.  
  1039. {--------------------------------------------------------------------------------------------------}
  1040.     {$S TRes}
  1041.  
  1042.     PROCEDURE TMABuildTool.Echo(aStr: Str255);
  1043.  
  1044.         BEGIN
  1045.         Write(fOutputFile^, '{MAEcho} ');
  1046.         WriteLn(fOutputFile^, aStr);
  1047.         END;
  1048.  
  1049. {--------------------------------------------------------------------------------------------------}
  1050.     {$S TRes}
  1051.  
  1052.     FUNCTION TMABuildTool.Exists(theFile: Str255): Boolean;
  1053.     { Return true if the file or directory exists }
  1054.  
  1055.         VAR
  1056.             fndrInfo:            FInfo;
  1057.             aCInfoPBRec:        CInfoPBRec;
  1058.  
  1059.         BEGIN
  1060.         WITH aCInfoPBRec DO
  1061.             BEGIN
  1062.             ioCompletion := NIL;
  1063.             ioNamePtr := @theFile;
  1064.             ioVRefNum := 0;
  1065.             ioFRefNum := 0;
  1066.             ioFDirIndex := 0;
  1067.             ioDirID := 0;
  1068.             END;
  1069.  
  1070.         Exists := (PBGetCatInfo(@aCInfoPBRec, FALSE) = noErr) & (aCInfoPBRec.IOResult = noErr);
  1071.         END;
  1072.  
  1073. {--------------------------------------------------------------------------------------------------}
  1074.     {$S TRes}
  1075.  
  1076.     PROCEDURE TMABuildTool.DoAllTargets;
  1077.  
  1078.         VAR
  1079.             aTStringHandle:     TStringHandle;
  1080.             aString, bString, XAppPath, XAppName, MAMakeFileExtension, MASetupExtension: Str255;
  1081.             ObjApp, SrcApp, SeparateObjectsFolder, BuildFlags, MABuildFlagsExtension: Str255;
  1082.             i:                    integer;
  1083.             automake, autorez, anyPascal, anyCPlus: Boolean;
  1084.             dirID:                Longint;
  1085.             MAShellVersion:     Str255;
  1086.  
  1087.         BEGIN
  1088.         { Process every target in fTargStringList }
  1089.         aTStringHandle := TStringHandle(fTargStringList.First);
  1090.  
  1091.         WHILE aTStringHandle <> NIL DO
  1092.             BEGIN
  1093.             fTargStringList.Delete(aTStringHandle);
  1094.  
  1095.             aString := aTStringHandle.AsStr255;         { Paths can't currently be longer than this
  1096.                                                          anyways! (MPW 3.1)}
  1097.  
  1098.             aTStringHandle.Free;
  1099.  
  1100.             { find the pathname and filename }
  1101.             XAppName := aString;
  1102.             XAppPath := '';
  1103.             FOR i := length(aString) DOWNTO 1 DO
  1104.                 BEGIN
  1105.                 IF Copy(aString, i, length(gDirectorySeparator)) = gDirectorySeparator THEN
  1106.                     BEGIN
  1107.                     XAppName := Copy(aString, i + 1, length(aString) - i);
  1108.                     XAppPath := Copy(aString, 1, i);
  1109.                     LEAVE;
  1110.                     END
  1111.                 END;
  1112.  
  1113.             { Automatically trim .MAMake off the target name if it was specified }
  1114.             IF IEGetEnv('MAMakeFileExtension', MAMakeFileExtension) & (MAMakeFileExtension <>
  1115.                '') THEN
  1116.                 BEGIN
  1117.                 aString := MAMakeFileExtension;
  1118.                 bString := XAppName;
  1119.                 UprStr255(aString);
  1120.                 UprStr255(bString);
  1121.                 i := pos(aString, bString);
  1122.                 IF (i <> 0) & (i + length(MAMakeFileExtension) - 1 = length(XAppName)) THEN
  1123.                     Delete(XAppName, i, length(MAMakeFileExtension));
  1124.                 END;
  1125.  
  1126.             { Blank path is current path }
  1127.             IF XAppPath = '' THEN
  1128.                 XAppPath := StartPath;
  1129.  
  1130.             SetIE('XAppPath', XAppPath);
  1131.             SetIE('XAppName', XAppName);
  1132.  
  1133.             { Check for the  MASetupExtension file }
  1134.             IF IEGetEnv('MASetupExtension', MASetupExtension) & Exists(concat(XAppPath, XAppName,
  1135.                                                                        MASetupExtension)) THEN
  1136.                 WriteLn(fOutputFile^, 'EXECUTE "', concat(XAppPath, XAppName, MASetupExtension),
  1137.                         '"');
  1138.  
  1139.             { Process separate objects into the source and object pathnames… }
  1140.             SeparateObjectsFolder := fSeparateObjectsFolder;
  1141.             ObjApp := concat(XAppPath, SeparateObjectsFolder);
  1142.             SrcApp := XAppPath;
  1143.             SetIE('ObjApp', ObjApp);
  1144.             SetIE('SrcApp', SrcApp);
  1145.  
  1146.             IF fProgress THEN
  1147.                 Echo('"Target Folder: ∂"{ObjApp}∂""');
  1148.  
  1149.             { Linkmap and LinkXref }
  1150.             IF fLinkMap THEN
  1151.                 BEGIN
  1152.                 IF fPerform THEN
  1153.                     SetIE('XLinkMap', '-la -lf -l > ∂''{ObjApp}{XAppName}.map∂'' ')
  1154.                 ELSE
  1155.                     SetIE('XLinkMap', '-la -lf -map > ∂''{ObjApp}{XAppName}.map∂'' ');
  1156.                 END
  1157.             ELSE
  1158.                 SetIE('XLinkMap', '');
  1159.  
  1160.             IF fLinkXRef THEN
  1161.                 SetIE('XLinkXRef', '-x ∂''{ObjApp}{XAppName}.xref∂'' ')
  1162.             ELSE
  1163.                 SetIE('XLinkXRef', '');
  1164.  
  1165.             { Get various file names for autodependencies }
  1166.             { in Pascal }
  1167.             anyPascal := FALSE;
  1168.             IF Exists(concat(SrcApp, 'U', XAppName, '.p')) THEN
  1169.                 BEGIN
  1170.                 anyPascal := TRUE;
  1171.                 SetIE('XUAppName.p', concat(SrcApp, 'U', XAppName, '.p'));
  1172.                 SetIE('XUAppName.p.o', concat(ObjApp, 'U', XAppName, '.p.o'));
  1173.                 END
  1174.             ELSE
  1175.                 BEGIN
  1176.                 SetIE('XUAppName.p', '');
  1177.                 SetIE('XUAppName.p.o', '');
  1178.                 END;
  1179.  
  1180.             IF Exists(concat(SrcApp, 'M', XAppName, '.p')) THEN
  1181.                 BEGIN
  1182.                 anyPascal := TRUE;
  1183.                 SetIE('XMAppName.p', concat(SrcApp, 'M', XAppName, '.p'));
  1184.                 SetIE('XMAppName.p.o', concat(ObjApp, 'M', XAppName, '.p.o'));
  1185.                 END
  1186.             ELSE
  1187.                 BEGIN
  1188.                 SetIE('XMAppName.p', '');
  1189.                 SetIE('XMAppName.p.o', '');
  1190.                 END;
  1191.  
  1192.             IF Exists(concat(SrcApp, XAppName, '.p')) THEN
  1193.                 BEGIN
  1194.                 anyPascal := TRUE;
  1195.                 SetIE('XAppName.p', concat(SrcApp, XAppName, '.p'));
  1196.                 SetIE('XAppName.p.o', concat(ObjApp, XAppName, '.p.o'));
  1197.                 END
  1198.             ELSE
  1199.                 BEGIN
  1200.                 SetIE('XAppName.p', '');
  1201.                 SetIE('XAppName.p.o', '');
  1202.                 END;
  1203.  
  1204.             { you should wonder at how long this next chunk took to write! }
  1205.             SetIE('EXIT', '0');
  1206.             SetIE('XUAppName.inc.p', '`(Files "{SrcApp}"U{XAppName}.≈.p) ≥ dev:null`');
  1207.             SetIE('EXIT', '1');
  1208.  
  1209.             { in C++ }
  1210.             anyCPlus := FALSE;
  1211.             IF Exists(concat(SrcApp, 'U', XAppName, '.h')) THEN
  1212.                 BEGIN
  1213.                 anyCPlus := TRUE;
  1214.                 fCPlusSupport := TRUE;
  1215.                 SetIE('XUAppName.h', concat(SrcApp, 'U', XAppName, '.h'));
  1216.                 END
  1217.             ELSE
  1218.                 BEGIN
  1219.                 SetIE('XUAppName.h', '');
  1220.                 END;
  1221.  
  1222.             IF Exists(concat(SrcApp, 'U', XAppName, '.cp')) THEN
  1223.                 BEGIN
  1224.                 anyCPlus := TRUE;
  1225.                 fCPlusSupport := TRUE;
  1226.                 SetIE('XUAppName.cp', concat(SrcApp, 'U', XAppName, '.cp'));
  1227.                 SetIE('XUAppName.cp.o', concat(ObjApp, 'U', XAppName, '.cp.o'));
  1228.                 END
  1229.             ELSE
  1230.                 BEGIN
  1231.                 SetIE('XUAppName.cp', '');
  1232.                 SetIE('XUAppName.cp.o', '');
  1233.                 END;
  1234.  
  1235.             IF Exists(concat(SrcApp, 'M', XAppName, '.cp')) THEN
  1236.                 BEGIN
  1237.                 anyCPlus := TRUE;
  1238.                 fCPlusSupport := TRUE;
  1239.                 SetIE('XMAppName.cp', concat(SrcApp, 'M', XAppName, '.cp'));
  1240.                 SetIE('XMAppName.cp.o', concat(ObjApp, 'M', XAppName, '.cp.o'));
  1241.                 END
  1242.             ELSE
  1243.                 BEGIN
  1244.                 SetIE('XMAppName.cp', '');
  1245.                 SetIE('XMAppName.cp.o', '');
  1246.                 END;
  1247.  
  1248.             IF Exists(concat(SrcApp, XAppName, '.cp')) THEN
  1249.                 BEGIN
  1250.                 anyCPlus := TRUE;
  1251.                 fCPlusSupport := TRUE;
  1252.                 SetIE('XAppName.cp', concat(SrcApp, XAppName, '.cp'));
  1253.                 SetIE('XAppName.cp.o', concat(ObjApp, XAppName, '.cp.o'));
  1254.                 END
  1255.             ELSE
  1256.                 BEGIN
  1257.                 SetIE('XAppName.cp', '');
  1258.                 SetIE('XAppName.cp.o', '');
  1259.                 END;
  1260.  
  1261.             { See if we can automake it }
  1262.             IF NOT Exists(concat(XAppPath, XAppName, MAMakeFileExtension)) THEN
  1263.                 BEGIN
  1264.                 automake := TRUE;
  1265.                 IF NOT (anyPascal | anyCPlus) THEN
  1266.                     BEGIN
  1267.                     Echo(
  1268. '''###'' MABuild: Bad parameter: Unable to access file: "{XAppPath}{XAppName}{MAMakeFileExtension}"'
  1269.                          );
  1270.                     Echo('MABuild of {XAppName} failed: `DATE`');
  1271.                     Execute('{MAFailed}');
  1272.  
  1273.                     IF fNoFail THEN
  1274.                         SetIE('XExitStatus', '1')
  1275.                     ELSE
  1276.                         Execute('EXIT 1');
  1277.                     END
  1278.                 END
  1279.             ELSE
  1280.                 automake := FALSE;
  1281.  
  1282.             { See if we can autorez it }
  1283.             IF NOT Exists(concat(XAppPath, XAppName, '.r')) THEN
  1284.                 BEGIN
  1285.                 autorez := TRUE;
  1286.                 SetIE('XAutoRez', '1');
  1287.                 SetIE('XAppRezSrc', '{MATools}Default.r');
  1288.                 END
  1289.             ELSE
  1290.                 BEGIN
  1291.                 autorez := FALSE;
  1292.                 SetIE('XAutoRez', '0');
  1293.                 SetIE('XAppRezSrc', '{XAppPath}{XAppName}.r');
  1294.                 END;
  1295.  
  1296.             { Make sure separate objects folder exists }
  1297.             IF NOT Exists(ObjApp) & (DirCreate(0, 0, ObjApp, dirID) <> noErr) THEN
  1298.                 BEGIN
  1299.                 Echo('''###'' MABuild: Unable to create directory: "{ObjApp}"');
  1300.                 Echo('MABuild of {XAppName} failed: `DATE`');
  1301.                 Execute('{MAFailed}');
  1302.  
  1303.                 IF fNoFail THEN
  1304.                     SetIE('XRunStatus', '1')
  1305.                 ELSE
  1306.                     Execute('EXIT 1');
  1307.                 END;
  1308.  
  1309.             { SET the BuildFlags }
  1310.             IF IEGetEnv('MABuildFlagsExtension', MABuildFlagsExtension) THEN;
  1311.             BuildFlags := concat(ObjApp, XAppName, MABuildFlagsExtension);
  1312.             SetIE('BuildFlags', BuildFlags);
  1313.  
  1314.             { Find out what the last option flags were }
  1315.             IF Exists(BuildFlags) THEN
  1316.                 Execute('EXECUTE "{BuildFlags}" ∑ Dev:Null || SET Status 0')
  1317.             ELSE
  1318.                 SetIE('XLastOptionFlags', 'InvalidString');
  1319.  
  1320.             IF fExecute THEN
  1321.                 BEGIN
  1322.                 Execute('IF {XLastOptionFlags} != {XOptionFlags}');
  1323.              { the file BuildFlags will contain a SET command to set the value of XLastOptionFlags }
  1324.                 Echo('"SET XLastOptionFlags {XOptionFlags}"  >  "{BuildFlags}"');
  1325.                 Execute('END');
  1326.                 END;
  1327.  
  1328.             { Rebuild the application by creating the "MakeIt" file and then executing it }
  1329.             SetIE('XMakeIt', '{ObjApp}{XAppName}{MAMakeOutfileExtension}');
  1330.  
  1331. { SET the failure processing mode in the makeit files and (OPTIONALLY) the active environment vars into the makefile }
  1332.             IF fNoFail THEN
  1333.                 Echo('SET EXIT 0  > "{XMakeIt}"')
  1334.             ELSE
  1335.                 Echo('SET EXIT 1  > "{XMakeIt}"');
  1336.  
  1337.             IF fExpandEnvironmentVars THEN
  1338.                 BEGIN
  1339.                 IF fStatusOnly THEN
  1340.                     SetIE('XMakeitRedirection', '')
  1341.                 ELSE
  1342.                     SetIE('XMakeitRedirection', ' >> ∂''{XMakeIt}∂''');
  1343.  
  1344.                 Execute('SET AsmOptions {XMakeitRedirection}');
  1345.                 Execute('SET BuildFlags {XMakeitRedirection}');
  1346.                 Execute('SET COptions {XMakeitRedirection}');
  1347.                 Execute('SET CPlusOptions {XMakeitRedirection}');
  1348.                 Execute('SET EchoOptions {XMakeitRedirection}');
  1349.                 Execute('SET LibOptions {XMakeitRedirection}');
  1350.                 Execute('SET LinkOptions {XMakeitRedirection}');
  1351.                 Execute('SET MakeOptions {XMakeitRedirection}');
  1352.                 Execute('SET ObjApp {XMakeitRedirection}');
  1353.                 Execute('SET PascalOptions {XMakeitRedirection}');
  1354.                 Execute('SET PostRezOptions {XMakeitRedirection}');
  1355.                 Execute('SET RezOptions {XMakeitRedirection}');
  1356.                 Execute('SET SeparateObjectsFolder {XMakeitRedirection}');
  1357.                 Execute('SET SrcApp {XMakeitRedirection}');
  1358.                 Execute('SET XAppName {XMakeitRedirection}');
  1359.                 Execute('SET XAppName.cp {XMakeitRedirection}');
  1360.                 Execute('SET XAppName.cp.o {XMakeitRedirection}');
  1361.                 Execute('SET XAppName.p {XMakeitRedirection}');
  1362.                 Execute('SET XAppName.p.o {XMakeitRedirection}');
  1363.                 Execute('SET XAppRezSrc {XMakeitRedirection}');
  1364.                 Execute('SET XAutoRez {XMakeitRedirection}');
  1365.                 Execute('SET XLinkMap {XMakeitRedirection}');
  1366.                 Execute('SET XLinkXRef {XMakeitRedirection}');
  1367.                 Execute('SET XMAppName.cp {XMakeitRedirection}');
  1368.                 Execute('SET XMAppName.cp.o {XMakeitRedirection}');
  1369.                 Execute('SET XMAppName.p {XMakeitRedirection}');
  1370.                 Execute('SET XMAppName.p.o {XMakeitRedirection}');
  1371.                 Execute('SET XTimes {XMakeitRedirection}');
  1372.                 Execute('SET XRunAfterBuild {XMakeitRedirection}');
  1373.                 Execute('SET XUAppName.cp {XMakeitRedirection}');
  1374.                 Execute('SET XUAppName.cp.o {XMakeitRedirection}');
  1375.                 Execute('SET XUAppName.h {XMakeitRedirection}');
  1376.                 Execute('SET XUAppName.p {XMakeitRedirection}');
  1377.                 Execute('SET XUAppName.p.o {XMakeitRedirection}');
  1378.                 END;
  1379.  
  1380.             { Export the various and sundry environment variables }
  1381.             IF NOT fEverExported THEN
  1382.                 BEGIN
  1383.                 fEverExported := TRUE;                    { only need to export once }
  1384.                 Execute('EXPORT ∂');
  1385.                 Execute(
  1386.       'AsmOptions BuildFlags COptions CPlusOptions EchoOptions LibOptions LinkOptions MakeOptions ∂'
  1387.                         );
  1388.                 Execute(
  1389. 'ObjApp PascalOptions PostRezOptions RezOptions SeparateObjectsFolder SrcApp XAppName XAppName.cp XAppName.cp.o ∂'
  1390.                         );
  1391.                 Execute(
  1392.              'XAppName.p XAppName.p.o XAppRezSrc XAutoRez XLinkMap XLinkXRef XMakeit XMAppName.cp ∂'
  1393.                         );
  1394.                 Execute('XMAppName.cp.o XMAppName.p XMAppName.p.o XTimes XRunAfterBuild ∂');
  1395.                 Execute(
  1396.                  'XUAppName.cp XUAppName.cp.o XUAppName.h XUAppName.inc.p XUAppName.p XUAppName.p.o'
  1397.                         );
  1398.                 END;
  1399.  
  1400.             { Give user makefile processing status message }
  1401.             IF fProgress THEN
  1402.                 BEGIN
  1403.                 IF automake THEN
  1404.                     Echo('"AutoMaking:    {XAppName}"')
  1405.                 ELSE
  1406.                     Echo('"Making:        {XAppName}{MAMakeFileExtension}"');
  1407.                 END;
  1408.  
  1409.             IF fTimes THEN
  1410.                 SetIE('XMakeStartTime', '`DATE -n`');
  1411.             SetIE('EXIT', '0');
  1412.  
  1413.             { run make }
  1414.             Execute('{MAMake} {MakeOptions} ∂');
  1415.  
  1416.             { Automatically include the CPLus libraries
  1417.             and select the proper FPU support.    !!! this is so hinky! (but its better than making MacApp users suffer!) }
  1418.             IF fCPlusSupport THEN
  1419.                 BEGIN
  1420.                 { Eliminate Pascal support }
  1421.                 Execute('-d PascalNonFPUSANELib=  ∂');
  1422.                 Execute('-d PascalFPUSANELib=  ∂');
  1423.                 Execute('-d PascalSupport=  ∂');
  1424.  
  1425.                 { Check if newer MPW 3.2 support }
  1426.                 IF IEGetEnv('MAShellVersion', MAShellVersion) & ((Copy(MAShellVersion, 1, 3) <>
  1427.                    '3.0') & (Copy(MAShellVersion, 1, 3) <> '3.1')) THEN
  1428.                     BEGIN
  1429.                     { Eliminate 3.0, 3.1 CPlus Support }
  1430.                     Execute('-d 31CPlusNonFPUSANELib=  ∂');
  1431.                     Execute('-d 31CPlusFPUSANELib=  ∂');
  1432.                     Execute('-d 31CPlusSupport=  ∂');
  1433.  
  1434.                     { Select the proper floating point support }
  1435.                     IF fNeedsFPU THEN
  1436.                         Execute('-d CPlusNonFPUSANELib=  ∂')
  1437.                     ELSE
  1438.                         Execute('-d CPlusFPUSANELib=  ∂');
  1439.                     END
  1440.                 ELSE
  1441.                     BEGIN
  1442.                     { Eliminate 3.2 CPlus Support }
  1443.                     Execute('-d CPlusNonFPUSANELib=  ∂');
  1444.                     Execute('-d CPlusFPUSANELib=  ∂');
  1445.                     Execute('-d CPlusSupport=  ∂');
  1446.  
  1447.                     { Select the proper floating point support }
  1448.                     IF fNeedsFPU THEN
  1449.                         Execute('-d 31CPlusNonFPUSANELib=  ∂')
  1450.                     ELSE
  1451.                         Execute('-d 31CPlusFPUSANELib=  ∂');
  1452.                     END
  1453.                 END
  1454.             ELSE
  1455.                 BEGIN
  1456.                 { Eliminate CPlus support }
  1457.                 Execute('-d 31CPlusNonFPUSANELib=  ∂');
  1458.                 Execute('-d 31CPlusFPUSANELib=  ∂');
  1459.                 Execute('-d 31CPlusSupport=  ∂');
  1460.                 Execute('-d CPlusNonFPUSANELib=  ∂');
  1461.                 Execute('-d CPlusFPUSANELib=  ∂');
  1462.                 Execute('-d CPlusSupport=  ∂');
  1463.  
  1464.                 { Select the proper floating point support }
  1465.                 IF fNeedsFPU THEN
  1466.                     Execute('-d PascalNonFPUSANELib=  ∂')
  1467.                 ELSE
  1468.                     Execute('-d PascalFPUSANELib=  ∂');
  1469.                 END;
  1470.  
  1471.             IF automake THEN
  1472.                 Execute('-d AppName={XAppName} ∂');     { the default rules supply the rest }
  1473.             Execute('-f "{MATools}Basic Definitions" ∂');
  1474.             IF NOT automake THEN
  1475.                 Execute('-f "{XAppPath}{XAppName}{MAMakeFileExtension}" ∂'); { a makefile was
  1476.                 supplied }
  1477.             Execute('-f "{MATools}Build Rules and Dependencies" ∂');
  1478.             Execute('"{ObjApp}{XAppName}" ∂');
  1479.             IF NOT fStatusOnly THEN
  1480.                 Execute('>> "{XMakeIt}"')
  1481.             ELSE
  1482.                 Execute('');
  1483.  
  1484.             SetIE('XMakeStatus', '{Status}');
  1485.             SetIE('EXIT', '1');
  1486.             Execute('IF "{XMakeStatus}"');
  1487.             Echo('MAKE of {XAppName} failed: `DATE`');
  1488.             IF fTimes THEN
  1489.                 Echo('Elapsed time: `evaluate ∂`DATE -n∂` - {XMakeStartTime}` seconds');
  1490.             Execute('{MAFailed}');
  1491.             IF fNoFail THEN
  1492.                 SetIE('XExitStatus', '{XMakeStatus}')
  1493.             ELSE
  1494.                 Execute('EXIT "{XMakeStatus}"');
  1495.  
  1496.             IF fTimes THEN
  1497.                 BEGIN
  1498.                 Execute('ELSE');
  1499.                 Echo('Elapsed time: `evaluate ∂`DATE -n∂` - {XMakeStartTime}` seconds');
  1500.                 END;
  1501.             Execute('END');
  1502.  
  1503.             { Attempt Execution and let the user know how it all came out }
  1504.             IF fExecute THEN
  1505.                 BEGIN
  1506.                 SetIE('EXIT', '0');
  1507.                 Execute('"{XMakeIt}"');
  1508.                 SetIE('XRunStatus', '{Status}');
  1509.                 SetIE('EXIT', '1');
  1510.                 Execute('IF "{XRunStatus}"');
  1511.                 Execute('{MAFailed}');
  1512.                 IF fNoFail THEN
  1513.                     SetIE('XExitStatus', '{XRunStatus}')
  1514.                 ELSE
  1515.                     Execute('EXIT "{XRunStatus}"');
  1516.                 Execute('END');
  1517.                 END;
  1518.             aTStringHandle := TStringHandle(fTargStringList.First);
  1519.             END;
  1520.         END;
  1521.  
  1522. {--------------------------------------------------------------------------------------------------}
  1523.     {$S TRes}
  1524.  
  1525.     PROCEDURE TMABuildTool.DoToolAction;
  1526.  
  1527.         VAR
  1528.             SeparateObjectsFolder, MASeparateObjectsPrefix: Str255;
  1529.             MAAutoBuild:        Str255;
  1530.             MAUserAutoBuild:    Str255;
  1531.             MAShortVersion:     Str255;
  1532.             MALoadFiles, LoadFileDir, CPlusLoad: Str255;
  1533.             aTStringHandle:     TStringHandle;
  1534.             aString:            Str255;
  1535.             dirID:                Longint;
  1536.             vRefNum:            integer;
  1537.  
  1538.             {* PathNameFromDirID ********************************************************}
  1539.  
  1540.         FUNCTION PathNameFromDirID(dirID: Longint;
  1541.                                    vRefNum: integer): Str255;
  1542.  
  1543.             CONST
  1544.                 fsRtDir             = 2;
  1545.  
  1546.             VAR
  1547.                 Block:                CInfoPBRec;
  1548.                 directoryName, FullPathName: Str255;
  1549.                 err:                oserr;
  1550.  
  1551.             BEGIN
  1552.             FullPathName := '';
  1553.             WITH Block DO
  1554.                 BEGIN
  1555.                 ioNamePtr := @directoryName;
  1556.                 ioDrParID := dirID;
  1557.                 END;
  1558.  
  1559.             REPEAT
  1560.                 WITH Block DO
  1561.                     BEGIN
  1562.                     ioVRefNum := vRefNum;
  1563.                     ioFDirIndex := - 1;
  1564.                     ioDrDirID := Block.ioDrParID;
  1565.                     END;
  1566.                 err := PBGetCatInfo(@Block, FALSE);
  1567.  
  1568.                 IF gConfiguration.hasAUX THEN
  1569.                     BEGIN
  1570.                     IF directoryName[1] <> '/' THEN
  1571.                         BEGIN
  1572.                         { If this isn't root (i.e. "/"), append a slash ('/') }
  1573.                         directoryName := concat(directoryName, '/');
  1574.                         END;
  1575.                     END
  1576.                 ELSE
  1577.                     BEGIN
  1578.                     directoryName := concat(directoryName, ':');
  1579.                     END;
  1580.                 FullPathName := concat(directoryName, FullPathName);
  1581.             UNTIL (Block.ioDrDirID = fsRtDir);
  1582.  
  1583.             PathNameFromDirID := FullPathName;
  1584.             END;
  1585.  
  1586.         BEGIN
  1587.  
  1588.         IF NOT IEGetEnv('MAShortVersion', MAShortVersion) | (MAShortVersion <> '2.0.1') THEN
  1589.             BEGIN
  1590.             Stop(
  1591.            '''###'' MABuild: Whoops… You have not executed the Startup file in the MacApp directory'
  1592.                  );
  1593.             END;
  1594.         { Resolve matrix of options. }
  1595.         IF NOT fProgress THEN
  1596.             fEchoOptions.Catenate(' ∑ Dev:Null ');
  1597.         IF fDebug THEN
  1598.             fNames := TRUE;
  1599.  
  1600. {!!!!!#### still need parsing loops to process each of these as multiple targets if the var is a list }
  1601.         IF fUserAutoBuild & IEGetEnv('MAUserAutoBuild', MAUserAutoBuild) & (MAUserAutoBuild <>
  1602.            '') THEN
  1603.             BEGIN
  1604.             aTStringHandle := NewTStringHandle;
  1605.             aTStringHandle.Catenate(MAUserAutoBuild);
  1606.             fTargStringList.InsertFirst(aTStringHandle);
  1607.             END;
  1608.  
  1609.         IF fAutoBuild & IEGetEnv('MAAutoBuild', MAAutoBuild) & (MAAutoBuild <> '') THEN
  1610.             BEGIN
  1611.             aTStringHandle := NewTStringHandle;
  1612.             aTStringHandle.Catenate(MAAutoBuild);
  1613.             fTargStringList.InsertFirst(aTStringHandle);
  1614.             END;
  1615.  
  1616.         { Building for use with MacApp? }
  1617.         IF fMacApp THEN
  1618.             CatenateToSourceOptionStrings(' -d qMacApp=TRUE')
  1619.         ELSE
  1620.             BEGIN
  1621.             CatenateToSourceOptionStrings(' -d qMacApp=FALSE');
  1622.             fOptionFlags.Catenate('Ge');    { Generic?, nm is taken already. }
  1623.             END;
  1624.  
  1625.         IF fAlign THEN
  1626.             BEGIN
  1627.             fLinkOptions.Catenate(' -ac 4 -ad 4');
  1628.             fRezOptions.Catenate(' -align longword');
  1629.             END;
  1630.  
  1631.         { process elapsed time indication }
  1632.         IF fTimes THEN
  1633.             BEGIN
  1634.             fAsmOptions.Catenate(' -t');
  1635.             fCOptions.Catenate(' -t');
  1636.             fCPlusOptions.Catenate(' -t');
  1637.             { fLinkOptions.Catenate(' -t'); # -t means file type}
  1638.             { fLibOptions.Catenate(' -t'); # there isn't a -t option}
  1639.             { fMakeOptions.Catenate(' -t'); # -t means touch the files}
  1640.             fPascalOptions.Catenate(' -t');
  1641.             { fRezOptions.Catenate(' -t');     # -t means file type}
  1642.             fPostRezOptions.Catenate(' -t');
  1643.             END;
  1644.  
  1645.         { Progress indication }
  1646.         IF fAllProgress THEN
  1647.             BEGIN
  1648.             CatenateToSourceOptionStrings(' -p');
  1649.             fLinkOptions.Catenate(' -p');
  1650.             fLibOptions.Catenate(' -p');
  1651.             fPostRezOptions.Catenate(' -p');
  1652.             END;
  1653.  
  1654.         IF fBottleNeckedDispatching THEN
  1655.             fLinkOptions.Catenate(' -opt NoBypass')
  1656.         ELSE
  1657.             fLinkOptions.Catenate(' -opt on');
  1658.  
  1659.         { Debug the Debugger }
  1660.         IF fDebugTheDebugger THEN
  1661.             BEGIN
  1662.             fOptionFlags.Catenate('DD');
  1663.  
  1664.             CatenateToSourceOptionStrings(' -d qDebugTheDebugger=TRUE')
  1665.             END
  1666.         ELSE
  1667.             CatenateToSourceOptionStrings(' -d qDebugTheDebugger=FALSE');
  1668.  
  1669.         { ROM 128K }
  1670.         IF fNeedsROM128K THEN
  1671.             CatenateToSourceOptionStrings(' -d qNeedsROM128K=TRUE')
  1672.         ELSE
  1673.             BEGIN
  1674.             fOptionFlags.Catenate('64');
  1675.  
  1676.             CatenateToSourceOptionStrings(' -d qNeedsROM128K=FALSE')
  1677.             END;
  1678.  
  1679.         { PreSystem 6.0 support }
  1680.         IF fNeedsSystem6 THEN
  1681.             BEGIN
  1682.             fOptionFlags.Catenate('S6');
  1683.  
  1684.             CatenateToSourceOptionStrings(
  1685. ' -d qNeedsScriptManager=TRUE -d qNeedsHierarchicalMenus=TRUE -d qNeedsStyleTextEdit=TRUE  -d qNeedsWaitNextEvent=TRUE'
  1686.                                           )
  1687.             END
  1688.         ELSE
  1689.             CatenateToSourceOptionStrings(
  1690. ' -d qNeedsScriptManager=FALSE -d qNeedsHierarchicalMenus=FALSE -d qNeedsStyleTextEdit=FALSE -d qNeedsWaitNextEvent=FALSE'
  1691.                                           );
  1692.  
  1693.         { ColorQD support }
  1694.         IF fNeedsColorQD THEN
  1695.             BEGIN
  1696.             fOptionFlags.Catenate('Cq');
  1697.  
  1698.             CatenateToSourceOptionStrings(' -d qNeedsColorQD=TRUE');
  1699.             END
  1700.         ELSE
  1701.             CatenateToSourceOptionStrings(' -d qNeedsColorQD=FALSE');
  1702.  
  1703.         { 020 support }
  1704.         IF fNeedsMC68020 THEN
  1705.             BEGIN
  1706.             fOptionFlags.Catenate('20');
  1707.  
  1708.             CatenateToSourceOptionStrings(' -d qNeedsMC68020=TRUE');
  1709.             fCOptions.Catenate(' -mc68020');
  1710.             fCPlusOptions.Catenate(' -mc68020');
  1711.             fPascalOptions.Catenate(' -mc68020');
  1712.             END
  1713.         ELSE
  1714.             CatenateToSourceOptionStrings(' -d qNeedsMC68020=FALSE');
  1715.  
  1716.         { 030 support }
  1717.         IF fNeedsMC68030 THEN
  1718.             BEGIN
  1719.             fOptionFlags.Catenate('30');
  1720.  
  1721.             CatenateToSourceOptionStrings(' -d qNeedsMC68030=TRUE');
  1722.             fCOptions.Catenate(' -mc68020');
  1723.             fCPlusOptions.Catenate(' -mc68020');
  1724.             fPascalOptions.Catenate(' -mc68020');
  1725.             END
  1726.         ELSE
  1727.             CatenateToSourceOptionStrings(' -d qNeedsMC68030=FALSE');
  1728.  
  1729.         { FPU support }
  1730.         IF fNeedsFPU THEN
  1731.             BEGIN
  1732.             fOptionFlags.Catenate('Fp');
  1733.  
  1734.             CatenateToSourceOptionStrings(' -d qNeedsFPU=TRUE');
  1735.             fCOptions.Catenate(' -mc68881 -elems881');
  1736.             fCPlusOptions.Catenate(' -mc68881 -elems881');
  1737.             fPascalOptions.Catenate(' -mc68881 -d elems881=TRUE');
  1738.             END
  1739.         ELSE
  1740.             BEGIN
  1741.             CatenateToSourceOptionStrings(' -d qNeedsFPU=FALSE');
  1742.             END;
  1743.  
  1744.         { MacApp as library support }
  1745.         IF fMALibrary THEN
  1746.             BEGIN
  1747.             fMakeOptions.Catenate(' -d MacAppObjs=  ');
  1748.             END
  1749.         ELSE
  1750.             BEGIN
  1751.             fMakeOptions.Catenate(' -d MacAppLibrary=  ');
  1752.             END;
  1753.  
  1754.         { Pascal external symbol table files support }
  1755.         IF NOT fPasLoad THEN
  1756.             BEGIN
  1757.             fMakeOptions.Catenate(' -d PascalLoad=  -d PascalLoadOptions=  '); { Remove the definitions }
  1758.             END;
  1759.  
  1760.         IF NOT fCPlusLoad THEN
  1761.             BEGIN
  1762.             fMakeOptions.Catenate(' -d CPlusLoad=  -d CPlusLoadOptions=  '); { Remove the definitions }
  1763.             END;
  1764.  
  1765.         { Embedded debugger names }
  1766.         IF fNames THEN
  1767.             BEGIN
  1768.             fOptionFlags.Catenate('Nm');
  1769.  
  1770.             CatenateToSourceOptionStrings(' -d qNames=TRUE');
  1771.             {$IFC FALSE}                                { !!! not until 32bit everything… gets too
  1772.                                                          big! }
  1773.             IF IEGetEnv('MAShellVersion', MAShellVersion) & (MAShellVersion <> '3.0') THEN
  1774.                 fLinkOptions.Catenate(' -opt names');    { Make the selector procs show up }
  1775.             {$EndC}
  1776.             END
  1777.         ELSE
  1778.             BEGIN
  1779.             CatenateToSourceOptionStrings(' -d qNames=FALSE');
  1780.             fCOptions.Catenate(' -mbg off');
  1781.             fCPlusOptions.Catenate(' -mbg off');
  1782.             END;
  1783.  
  1784.         { Debugging support }
  1785.         IF fDebug THEN
  1786.             BEGIN
  1787.             fOptionFlags.Catenate('Db');
  1788.  
  1789.             CatenateToSourceOptionStrings(' -d qDebug=TRUE');
  1790.             fRezOptions.Catenate(' -d Debugging');        { For backward compatibility. To be dropped
  1791.                                                          in next release (post 2.0)}
  1792.             END
  1793.         ELSE
  1794.             BEGIN
  1795.             CatenateToSourceOptionStrings(' -d qDebug=FALSE');
  1796.             fMakeOptions.Catenate(' -d DebugFiles= -d DebugRsrcs= -d DebugLib=  '); { Eliminate
  1797.                 debug files as targets in the makefiles }
  1798.             END;
  1799.  
  1800.         { Inspector support }
  1801.         IF fInspector THEN
  1802.             BEGIN
  1803.             fOptionFlags.Catenate('In');
  1804.  
  1805.             CatenateToSourceOptionStrings(' -d qInspector=TRUE');
  1806.             END
  1807.         ELSE
  1808.             CatenateToSourceOptionStrings(' -d qInspector=FALSE');
  1809.  
  1810.         { UnInitialized storage support }
  1811.         IF fUnInit THEN
  1812.             BEGIN
  1813.             fOptionFlags.Catenate('Un');
  1814.  
  1815.             CatenateToSourceOptionStrings(' -d qUnInit=TRUE');
  1816.             END
  1817.         ELSE
  1818.             CatenateToSourceOptionStrings(' -d qUnInit=FALSE');
  1819.  
  1820.         { Perform support }
  1821.         IF fPerform THEN
  1822.             BEGIN
  1823.             fOptionFlags.Catenate('Pe');
  1824.  
  1825.             CatenateToSourceOptionStrings(' -d qPerform=TRUE');
  1826.             END
  1827.         ELSE
  1828.             BEGIN
  1829.             CatenateToSourceOptionStrings(' -d qPerform=FALSE');
  1830.             fMakeOptions.Catenate(' -d PerformLib= ');    { Eliminate the performance libraries as
  1831.                                                          target }
  1832.             END;
  1833.  
  1834.         { RangeCheck support }
  1835.         IF fRangeCheck THEN
  1836.             BEGIN
  1837.             fOptionFlags.Catenate('Ra');
  1838.  
  1839.             CatenateToSourceOptionStrings(' -d qRangeCheck=TRUE');
  1840.             END
  1841.         ELSE
  1842.             CatenateToSourceOptionStrings(' -d qRangeCheck=FALSE');
  1843.  
  1844.         { Trace support }
  1845.         IF fTrace THEN
  1846.             BEGIN
  1847.             fOptionFlags.Catenate('Tr');
  1848.  
  1849.             CatenateToSourceOptionStrings(' -d qTrace=TRUE');
  1850.             END
  1851.         ELSE
  1852.             CatenateToSourceOptionStrings(' -d qTrace=FALSE');
  1853.  
  1854.         { template views support }
  1855.         IF fTemplateViews THEN
  1856.             BEGIN
  1857.             fOptionFlags.Catenate('Te');
  1858.  
  1859.             CatenateToSourceOptionStrings(' -d qTemplateViews=TRUE');
  1860.             END
  1861.         ELSE
  1862.             CatenateToSourceOptionStrings(' -d qTemplateViews=FALSE');
  1863.  
  1864.         { symbolic debugging support }
  1865.         IF fSym THEN
  1866.             BEGIN
  1867.             fOptionFlags.Catenate('Sm');
  1868.  
  1869.             CatenateToSourceOptionStrings(' -d qSym=TRUE');
  1870.             fAsmOptions.Catenate(' -sym on');
  1871.             fCOptions.Catenate(' -sym on');
  1872.             fCPlusOptions.Catenate(' -sym on');
  1873.             fLinkOptions.Catenate(' -sym on');
  1874.             fPascalOptions.Catenate(' -sym on');
  1875.             END
  1876.         ELSE
  1877.             CatenateToSourceOptionStrings(' -d qSym=FALSE');
  1878.  
  1879.         { See if user wants to play with experimental and _UNSUPPORTED_ goodies. }
  1880.         IF fExperimentalAndUnsupported THEN
  1881.             BEGIN
  1882.             fOptionFlags.Catenate('Ex');
  1883.  
  1884.             CatenateToSourceOptionStrings(' -d qExperimentalAndUnsupported=TRUE');
  1885.             END
  1886.         ELSE
  1887.             CatenateToSourceOptionStrings(' -d qExperimentalAndUnsupported=FALSE');
  1888.  
  1889.         { Process separate objects }
  1890.         { Get basic name }
  1891.         IF fSeparateObjects THEN
  1892.             BEGIN
  1893.             IF NOT fRenameFlagsPairs.ValueAt(fOptionFlags.AsStr255, SeparateObjectsFolder) THEN
  1894.                 SeparateObjectsFolder := fOptionFlags.AsStr255;
  1895.             END
  1896.         ELSE
  1897.             BEGIN
  1898.             IF NOT IEGetEnv('MANoSeparateObjectsFolder', SeparateObjectsFolder) THEN
  1899.                 SeparateObjectsFolder := '';
  1900.             END;
  1901.  
  1902.         { Add the prefix }
  1903.         IF IEGetEnv('MASeparateObjectsPrefix', MASeparateObjectsPrefix) THEN
  1904.             SeparateObjectsFolder := concat(MASeparateObjectsPrefix, SeparateObjectsFolder,
  1905.                                             gDirectorySeparator);
  1906.  
  1907.         SetIE('SeparateObjectsFolder', SeparateObjectsFolder);
  1908.         fSeparateObjectsFolder := SeparateObjectsFolder;
  1909.  
  1910.         { output the results. }
  1911.         IF fTimes THEN
  1912.             WriteLn(fOutputFile^, 'SET XStartTime ', fStartDateTime);
  1913.         WriteLn(fOutputFile^, 'SET XTimes ', ord(fTimes));
  1914.         WriteLn(fOutputFile^, 'SET XRunAfterBuild ', ord(fRunAfterBuild));
  1915.  
  1916.         Write(fOutputFile^, 'SET AsmOptions "'); fAsmOptions.WriteToFile(fOutputFile);
  1917.         WriteLn(fOutputFile^, ' "');
  1918.         Write(fOutputFile^, 'SET COptions "'); fCOptions.WriteToFile(fOutputFile);
  1919.         WriteLn(fOutputFile^, ' "');
  1920.         Write(fOutputFile^, 'SET CPlusOptions "'); fCPlusOptions.WriteToFile(fOutputFile);
  1921.         WriteLn(fOutputFile^, ' "');
  1922.         Write(fOutputFile^, 'SET EchoOptions "'); fEchoOptions.WriteToFile(fOutputFile);
  1923.         WriteLn(fOutputFile^, ' "');
  1924.         Write(fOutputFile^, 'SET LibOptions "'); fLibOptions.WriteToFile(fOutputFile);
  1925.         WriteLn(fOutputFile^, ' "');
  1926.         Write(fOutputFile^, 'SET LinkOptions "'); fLinkOptions.WriteToFile(fOutputFile);
  1927.         WriteLn(fOutputFile^, ' "');
  1928.         Write(fOutputFile^, 'SET MakeOptions "'); fMakeOptions.WriteToFile(fOutputFile);
  1929.         WriteLn(fOutputFile^, ' "');
  1930.         Write(fOutputFile^, 'SET PascalOptions "'); fPascalOptions.WriteToFile(fOutputFile);
  1931.         WriteLn(fOutputFile^, ' "');
  1932.         Write(fOutputFile^, 'SET RezOptions "'); fRezOptions.WriteToFile(fOutputFile);
  1933.         WriteLn(fOutputFile^, ' "');
  1934.         Write(fOutputFile^, 'SET PostRezOptions "'); fPostRezOptions.WriteToFile(fOutputFile);
  1935.         WriteLn(fOutputFile^, ' "');
  1936.  
  1937.         Write(fOutputFile^, 'SET XOptionFlags "'); fOptionFlags.WriteToFile(fOutputFile);
  1938.         WriteLn(fOutputFile^, '"');
  1939.  
  1940.         { Process autosave }
  1941.         IF fSaveBeforeBuild THEN
  1942.             BEGIN
  1943.             IF fProgress THEN
  1944.                 Echo('"AutoSaving…"');
  1945.             Execute('Save -a');
  1946.             END;
  1947.  
  1948.         { Remember the current directory }
  1949.         IF HGetVol(NIL, vRefNum, dirID) = noErr THEN
  1950.             StartPath := PathNameFromDirID(dirID, vRefNum);
  1951.  
  1952.         { Make sure load files folder and separate objects folder exists for load files}
  1953.         IF IEGetEnv('MALoadFiles', MALoadFiles) THEN
  1954.             LoadFileDir := concat(MALoadFiles, fSeparateObjectsFolder)
  1955.         ELSE                                        { Punt }
  1956.             LoadFileDir := concat(MALoadFiles, fSeparateObjectsFolder);
  1957.         { Make sure the basic load files directory exists }
  1958.         IF (MALoadFiles <> '') & NOT Exists(MALoadFiles) & (DirCreate(0, 0, MALoadFiles,
  1959.            dirID) <> noErr) THEN
  1960.             BEGIN
  1961.             Echo('''###'' MABuild: Unable to create directory: "{MALoadFiles}"');
  1962.             Echo('MABuild of {XAppName} failed: `DATE`');
  1963.             Execute('{MAFailed}');
  1964.  
  1965.             IF fNoFail THEN
  1966.                 SetIE('XRunStatus', '1')
  1967.             ELSE
  1968.                 Execute('EXIT 1');
  1969.             END;
  1970.         { Make sure the load files directory that is specific to our build options exists }
  1971.         IF NOT Exists(LoadFileDir) & (DirCreate(0, 0, LoadFileDir, dirID) <> noErr) THEN
  1972.             BEGIN
  1973.             Echo(
  1974.            '''###'' MABuild: Unable to create directory: "{MALoadFiles}{SeparateObjectsFolder}"'
  1975.                  );
  1976.             Echo('MABuild of {XAppName} failed: `DATE`');
  1977.             Execute('{MAFailed}');
  1978.  
  1979.             IF fNoFail THEN
  1980.                 SetIE('XRunStatus', '1')
  1981.             ELSE
  1982.                 Execute('EXIT 1');
  1983.             END;
  1984.  
  1985.         { process each target in the list }
  1986.         DoAllTargets;
  1987.  
  1988.         { termination messages }
  1989.         IF fTimes THEN
  1990.             BEGIN
  1991.             Echo('" "');
  1992.             Echo('MABuild:   Elapsed time: `evaluate ∂`DATE -n∂` - {XStartTime}` seconds');
  1993.             END;
  1994.  
  1995.         Execute('IF "{XExitStatus}"');
  1996.         Execute('{MAFailed}');
  1997.         Execute('EXIT "{XExitStatus}"');
  1998.         Execute('END');
  1999.  
  2000.         IF fProgress THEN
  2001.             BEGIN
  2002.             Echo('Completion time for MABuild is `DATE`');
  2003.             Execute('{MADone}');
  2004.             END;
  2005.         END;
  2006. {--------------------------------------------------------------------------------------------------}
  2007.     {$S TRes}
  2008.  
  2009.     BEGIN
  2010.     InitUMPWTool;
  2011.  
  2012.     New(gMABuildTool);
  2013.     gMABuildTool.IMABuildTool;
  2014.     gMABuildTool.Run;
  2015.     END.
  2016.